package com.itbbfx.service.pharmacymanager.impl;

import com.itbbfx.entity.Baoque;
import com.itbbfx.entity.Huishou;
import com.itbbfx.entity.Ypharmacy;
import com.itbbfx.mapper.PharmacyMapper;
import com.itbbfx.service.pharmacymanager.PharmacyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PharmacyServiceImpl implements PharmacyService {
    @Autowired
    private PharmacyMapper pharmacyMapper;

    @Override
    public int addPharmacy(Ypharmacy ypharmacy) {
        Ypharmacy y = pharmacyMapper.queryPharmacy(ypharmacy); // 查询药房有没有药品
        if(y != null){
            y.setSkullbatch(ypharmacy.getSkullbatch());
            return pharmacyMapper.updatePharmacy(y);
        }else{
            return pharmacyMapper.addPharmacy(ypharmacy);
        }
    }

    @Override
    public int delpharymacy(Ypharmacy ypharmacy) {
        return pharmacyMapper.delpharymacy(ypharmacy);
    }

    @Override
    public int addhuishou(Huishou huishou) {
        return pharmacyMapper.addhuishou(huishou);
    }

    @Override
    public List<Huishou> selhuishou(Huishou huishou) {
        return pharmacyMapper.selhuishou(huishou);
    }

    @Override
    public int delhuishou(Huishou huishou) {
        return pharmacyMapper.delhuishou(huishou);
    }

    @Override
    public int addbaoque(Baoque baoque) {
        return pharmacyMapper.addbaoque(baoque);
    }

    @Override
    public int selbaoqueName(Baoque baoque) {
        return pharmacyMapper.selbaoqueName(baoque);
    }

    @Override
    public int upbaoquenum(Baoque baoque) {
        return pharmacyMapper.upbaoquenum(baoque);
    }
    
    @Override
    public List<Ypharmacy> selectall() {
        return pharmacyMapper.selectall();
    }

    @Override
    public List<Ypharmacy> selpharmacy(Ypharmacy ypharmacy) {
        return pharmacyMapper.selpharmacy(ypharmacy);
    }

    @Override
    public int cleanExpiredpharmacy(Ypharmacy ypharmacy) {
        return pharmacyMapper.cleanExpiredpharmacy(ypharmacy);
    }
}